package com.sponsorpay.sdk.android.utils;

import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;
import java.security.KeyManagementException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.Principal;
import java.security.UnrecoverableKeyException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;

public class SPSSLSocketFactory extends org.apache.http.conn.ssl.SSLSocketFactory
{
  private final SSLContext sslContext = SSLContext.getInstance("TLS");

  public SPSSLSocketFactory(KeyStore paramKeyStore)
    throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException
  {
    super(paramKeyStore);
    X509TrustManager local1 = new X509TrustManager()
    {
      public void checkClientTrusted(X509Certificate[] paramAnonymousArrayOfX509Certificate, String paramAnonymousString)
        throws CertificateException
      {
      }

      public void checkServerTrusted(X509Certificate[] paramAnonymousArrayOfX509Certificate, String paramAnonymousString)
        throws CertificateException
      {
        if ((!paramAnonymousArrayOfX509Certificate[0].getSubjectDN().getName().matches(".*\\.sponsorpay\\.com.*")) || (!paramAnonymousArrayOfX509Certificate[0].getIssuerDN().getName().matches(".*StartCom Ltd.*")))
          throw new CertificateException();
        for (int i = 0; ; i++)
        {
          if (i >= -1 + paramAnonymousArrayOfX509Certificate.length)
            return;
          if (!paramAnonymousArrayOfX509Certificate[i].getIssuerDN().getName().equals(paramAnonymousArrayOfX509Certificate[(i + 1)].getSubjectDN().getName()))
            throw new CertificateException();
        }
      }

      public X509Certificate[] getAcceptedIssuers()
      {
        return null;
      }
    };
    this.sslContext.init(null, new TrustManager[] { local1 }, null);
  }

  public Socket createSocket()
    throws IOException
  {
    return this.sslContext.getSocketFactory().createSocket();
  }

  public Socket createSocket(Socket paramSocket, String paramString, int paramInt, boolean paramBoolean)
    throws IOException, UnknownHostException
  {
    return this.sslContext.getSocketFactory().createSocket(paramSocket, paramString, paramInt, paramBoolean);
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.sponsorpay.sdk.android.utils.SPSSLSocketFactory
 * JD-Core Version:    0.6.2
 */